# -*- mode: python; coding: utf-8; -*-
##--------------------------------------------------------------------------##
##
## Copyright (C) 1998-2003 Markus Oberhumer <markus@oberhumer.com>
## Copyright (C) 2003 Mt. Hood Playing Card Co.
## Copyright (C) 2005-2010 Skomoroh <skomoroh@users.sourceforge.net>
## Copyright (C) 2010-2013 Jeremy Austin-Bardo <tjaustinbardo@gmail.com>
##
## This program is free software: you can redistribute it and/or modify
## it under the terms of the GNU General Public License as published by
## the Free Software Foundation, either version 3 of the License.
##
## This program is distributed in the hope that it will be useful,
## but WITHOUT ANY WARRANTY; without even the implied warranty of
## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
## GNU General Public License for more details.
##
## You should have received a copy of the GNU General Public License
## along with this program.  If not, see <http://www.gnu.org/licenses/>.
##
##--------------------------------------------------------------------------##
"""
Numerica Style Stacks
"""

from .. import hint
from .. import pilelib as stack
from .. import helpstrings as hs


class Hint(hint.DefaultHint):

    def score_move_waste(self, from_stack, to_stack, pile, rpile):
        """
        score_move_waste(from_stack:Stack, to_stack:Stack, pile:seq(Card ...),
          rpile:seq(Card ...)) -> None

        Score moving a pile (usually 1 card) from Waste.
        """
        talon_group = self._stacks['grp']['Talon']
        assert from_stack in talon_group and len(pile) == 1
        self._score = 30000
        to_rank, from_rank = to_stack.TOPCARD['rank'], from_stack.BASECARD['rank']
        if not to_rank:
            self._score -= 1000 * (self.K - from_rank)
        elif to_rank < pile[0]['rank']:
            self._score = 10000 + to_rank - len(to_stack.cards)
        elif to_rank == pile[0]['rank']:
            self._score -= 10000
        else:
            self._score -= 1000 * (to_rank - from_rank)


class CautiousHint(hint.CautiousHintMethods, Hint):
    pass


class Strategy_RowStack(stack.FromTalonBuildMethod,
                        stack.EmptyTalonPlayMethod, stack.BasicRowStack):
    _BOTTOM_IMAGE_ = 'shade'

    @property
    def _helpString(self):
        """
        _helpString -> str

        :return: helpful string about pile for its canvas label.
        :rtype:  base_string
        """
        return hs.BUILD_REGARDLESS


class Colorado_RowStack(stack.FromWasteBuildMethod, stack.ReserveStack):
    pass


class SlyFox_RowStack(stack.FromTalonBuildMethod, stack.ReserveStack):
    pass